package com.cgc.venus.server.log.controller;

import com.cgc.venus.server.core.bean.response.VenusResponse;
import com.cgc.venus.server.core.bean.response.VenusResponseStatus;
import com.cgc.venus.server.core.exception.VenusException;
import com.cgc.venus.server.log.inter.ExLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Created by 业哥 on 2017/11/29.
 */
@Api(value = "平台异常日志管理",description="平台异常日志管理所对应服务的api")
@RequestMapping("/exLog-admin")
@RestController
public class ExLogController {
    @Autowired
    private ExLogService exLogServiceImpl;
    @ApiOperation("异常日志模块查询")
    @RequestMapping(value = "/exLogModule", method = RequestMethod.GET)
    @ResponseBody
    public VenusResponse<List> exLogModuleQuery() throws VenusException {
        List result=exLogServiceImpl.queryExModule();
        VenusResponse<List> response=new VenusResponse<List>(VenusResponseStatus.OK,"",result);
        return response;
    }

    @ApiOperation("异常日志查询")
    @RequestMapping(value = "/exLog", method = RequestMethod.GET)
    @ResponseBody
    public VenusResponse<Map> exLogQuery(@RequestParam("module") String module,
                                               @RequestParam("type") String type,
                                               @RequestParam("timeStart") String timeStart,
                                               @RequestParam("timeEnd") String timeEnd,
                                               @RequestParam(value = "queryKey",required = false) String queryKey,
                                               @RequestParam("currentPage") int currentPage) throws VenusException {
        Map map=exLogServiceImpl.queryEx(module,type,timeStart,timeEnd,queryKey,currentPage);
        VenusResponse<Map> response=new VenusResponse<Map>(VenusResponseStatus.OK,"",map);
        return response;
    }
}